package com.example.makerspace.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.makerspace.domain.ProductBulletinsDO;
import com.example.makerspace.domain.UserDO;
import com.example.makerspace.mapper.NoticeMapper;
import com.example.makerspace.mapper.ProductBulletinsMapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;


@Component
public class ProductBulletinsDAO   extends  BaseDAO<ProductBulletinsDO>{

    @Resource
    private ProductBulletinsMapper productBulletinsMapper;

    @PostConstruct
    public void init(){
        this.mapper = productBulletinsMapper;
    }

    public Page<ProductBulletinsDO> selectByPage(Page<ProductBulletinsDO> page, String name) {
        LambdaQueryWrapper<ProductBulletinsDO> qw = new LambdaQueryWrapper<ProductBulletinsDO>();
          qw.like(StringUtils.isNotEmpty(name),ProductBulletinsDO::getTitle,name).or()
                  .like(StringUtils.isNotEmpty(name),ProductBulletinsDO::getContent,name);

          return  mapper.selectPage(page,qw);

    }
}
